<?php
/**
  * //w/w/w.s/h/u/o/t//u/p/u c/o/m  说 图/谱/源/码/分/享
 */
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/6 0006
 * Time: 15:00
 */
defined("IN_IA")or exit("Access denied");
global $_GPC,$_W;
$uniacid=$_GPC['uniacid'];
$op=$_GPC['op'] ? $_GPC['op'] :"getArticleData";
$uid=$_GPC['uid'];
if($op=='getArticleData'){
    $request=array();
    if(empty($_GPC['page'])){
        $page=1;
    }else{
        $page=$_GPC['page'];
    }
    $type_id=$_GPC['type_id'];
    if($type_id!=0){
        $articleData = pdo_getall('cqkundian_farm_article', array('uniacid' => $uniacid,'type_id'=>$type_id), '', '', 'rank asc', array($page, 10));
    }else {
        $typeData = pdo_getall('cqkundian_farm_article_type', array('uniacid' => $uniacid));
        $articleData = pdo_getall('cqkundian_farm_article', array('uniacid' => $uniacid), '', '', 'rank asc', array($page, 10));
        $request['typeData']=$typeData;
    }
    $request['articleData']=$articleData;
    echo json_encode($request);die;
}

//获取资讯详情
if($op=='getArticleDetail'){
    $request=array();
    $aid=$_GPC['aid'];
    //更新浏览记录
    pdo_update('cqkundian_farm_article',array('view_count +='=>1),array('uniacid'=>$uniacid,'id'=>$aid));
    $articleDetail=pdo_get('cqkundian_farm_article',array('uniacid'=>$uniacid,'id'=>$aid));
    $articleDetail['create_time']=date("Y-m-d",$articleDetail['create_time']);
    $request['articleDetail']=$articleDetail;
    echo json_encode($request);die;
}